package com.wiserun.develop.project.controller;

import com.wiserun.develop.project.model.Project;
import com.wiserun.develop.project.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/project")
public class ProjectController {
    @Autowired
    private ProjectService projectService;

    @RequestMapping("/select")
    public List<Project> queryList(@RequestBody(required = false) Project project){
        List<Project> projects = projectService.queryList(project);
        return projects;
    }

    @RequestMapping("/add")
    public int add(@RequestBody Project record){
        int add = projectService.add(record);
        return add;

    };

    @PostMapping("/update")
    public int update(@RequestBody Project project){
        int update = projectService.update(project);
        return update;
    };

    @RequestMapping("/delete")
    public int delete(@RequestParam("id") Integer id){
        int delete = projectService.delete(id);
        return delete;
    };
}
